<?php
/**
 * CreateTime: 2022/8/4 10:26
 */

namespace App\Func;

use App\Func\ScopeFunc\AuthScopeStaffFunc;
use App\Models\Staff\StaffModel;
use App\Scopes\MediationStaffScope;

class StaffFunc
{

    public static function getStaffAllBySelect(){
        $staffModel = new StaffModel();
        $res =  $staffModel->select(["staff_id","staff_name"])
            # 禁止全局 手动处理
            ->withoutGlobalScope(MediationStaffScope::class)
            ->whereIn('staff.staff_id',AuthScopeStaffFunc::getDepartmentStaffByCurrentStaffId())
            ->get();
        if($res){
            return $res->toArray();
        }
        return [];
    }
    public static function getStaffNameByStaffId($staffAll,$staffId){
        $newStaffAll = array_column($staffAll,'staff_name','staff_id');
        return isset($newStaffAll[$staffId]) ? $newStaffAll[$staffId] : "";
    }
}